package com.ljx.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author LJX
 * @Description: TODO
 * @Date: 2022/12/27 16:42
 * @Version 1.0
 */
@Configuration
public class EsConfig {
	// 把方法的返回值交于spring容器管理
	@Bean
	public RestHighLevelClient restHighLevelClient(){
		HttpHost host = new HttpHost("localhost",9200,"http");
		RestClientBuilder restClientBuilder = RestClient.builder(host);
		RestHighLevelClient restHighLevelClient = new RestHighLevelClient(restClientBuilder);
		return restHighLevelClient;
	}
}
